package uiLayer;
import modelLayer.*;
import controlLayer.*;
import java.util.Scanner;

/**
 * UI that prompts the user to either work with a DVD or a Copy.
 * 
 * @author (Gruppe E) 
 * @version (06-11-2014)
 */
public class DvdMainUI
{
    private DvdUI dvdUI;
    private CopyUI copyUI;

    /**
     * Constructor for objects of class DvdMainMenu
     */
    public DvdMainUI(DVDController controller)
    {
        dvdUI = new DvdUI(controller);
        copyUI = new CopyUI(controller);
    }

    /**
     * Calls the private method mainMenu();
     */
    public void start()
    {
        dvdMainMenu();
    }

    /**
     * Runs a while-loop, prompting the user for input and calls the sub-menus.
     */
    private void dvdMainMenu()
    {
        boolean exit = false;

        while(!exit)
        {
            int choice = writeDvdMainMenu();
            if(choice == 1)
            {
                dvdUI.start();
            }

            else if(choice == 2)
            {
                copyUI.start();
            }

            else if(choice == 3)
            {
                exit = true;
            }

            else
            {
                System.out.println("\nInvalid types. Please try again.");
            }
        }
    }

    /**
     * A private method that displays a set of options and promts the user to enter an int.
     * @return  int
     */
    private int writeDvdMainMenu()
    {
        Scanner keyboard = new Scanner(System.in);
        blankLines();
        System.out.println("\nDvdMainUI");
        System.out.println("*** DvdMenu ***");
        System.out.println("1. DVD");
        System.out.println("2. Copy");
        System.out.println("3. Back");
        System.out.println("\nPlease choose either DVD or Copy");

        int choice = keyboard.nextInt();
        return choice;
    }

    /**
     * This method adds 5 blank lines.
     */
    private void blankLines()
    {
        for(int i = 0; i < 5; i++)
        {
            System.out.println();
        }
    }
}
